import { data } from '@/pages/question/editor/data';
import { useEditorStore } from '@/store/editor';
import { usePageInfoStore } from '@/store/pageInfo';
import { useEffect } from 'react';

export function useEditorData() {
  // const { id } = useParams();
  const { reset: resetComponentList } = useEditorStore();
  const { reset: resetInfo } = usePageInfoStore();
  const { componentList, title, desc, js, css } = data;

  let selectedId = '';
  if (componentList.length) {
    selectedId = componentList[0].fe_id || '';
  }

  useEffect(() => {
    resetComponentList({ componentList, selectedId });
    resetInfo({ title, desc, js, css });
  }, []);

  return [data];
}
